import request from '@/utils/request1'

export interface categoryView {
  id: number
  category1Id: number
  category1Name: string
  category2Id: number
  category2Name: string
  category3Id: number
  category3Name: string
}

export interface spuSaleAttrValueList {
  id: number
  spuId: number
  baseSaleAttrId: number
  saleAttrValueName: string
  saleAttrName: string
  isChecked: number
}

export interface spuSaleAttrList {
  id: number
  spuId: number
  baseSaleAttrId: number
  saleAttrName: string
  spuSaleAttrValueList: spuSaleAttrValueList[]
}

export interface skuImageList {
  id: number
  skuId: number
  imgName: string
  imgUrl: string
  spuImgId: number
}

export interface skuAttrValueList {
  id: number
  attrId: number
  valueId: number
  skuId: number
}

export interface skuInfo {
  createTime: string
  id: number
  spuId: number
  price: number
  skuName: string
  skuDesc: string
  weight: number
  tmId: number
  category3Id: number
  skuDefaultImg: string
  isSale: number
  skuImageList: skuImageList[]
  skuAttrValueList: skuAttrValueList[]
  skuSaleAttrValueList: skuSaleAttrValueList[]
}

export interface skuSaleAttrValueList{
    id: number
    saleAttrId: number
    saleAttrName: string
    saleAttrValueId: number
    saleAttrValueName: string
    skuId: number
    spuId:number
}

export interface detail {
  price: number
  categoryView: categoryView
  spuSaleAttrList: spuSaleAttrList[]
  skuInfo: skuInfo
}

export interface data {
  data:detail
}

export interface list{
  code:number
}
export const getShopDetail = (skuId: number) => {
  return request.get<any, data>(`/api/item/${skuId}`)
}

export const getShopList= (skuId:number,skuNum:number)=>{
    return request.post<any,list>(`/api/cart/addToCart/${skuId}/${skuNum}`)
}